package com.ylxin.dao.impl;

import com.ylxin.dao.UserDao;
import com.ylxin.entity.User;
import com.ylxin.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * @author Hou
 * @version V1.0
 * @Project day42
 * @Package com.qf.dao.impl
 * @Description:
 * @Date 2022/5/12 9:59
 */
public class UserDaoImpl implements UserDao {
    private QueryRunner runner = new QueryRunner(DBUtil.getDateSource());
    @Override
    public User selectUser(String uname, String pwd) {
        String sql = "select * from t_users where username=? and password = ?";
        try {
            return runner.query(sql,new BeanHandler<>(User.class),uname,pwd);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
